import java.lang.reflect.Parameter;
import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/8 17:21
 * @description 贪心，肯定每次选最多数量的单词添加到末尾，如果超过三个，那么选择下一个字符来添加
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.longestDiverseString(1, 1, 7);
    }
    public String longestDiverseString(int a, int b, int c) {
        PriorityQueue<int[]> q = new PriorityQueue<>((x,y)->y[1]-x[1]);
        if (a > 0) {
            q.add(new int[]{0, a});
        }
        if (b > 0) {
            q.add(new int[]{1, b});
        }
        if (c > 0) {
            q.add(new int[]{2, c});
        }
        StringBuilder sb = new StringBuilder();
        while (!q.isEmpty()) {
            int[] cur = q.poll();
            int n = sb.length();
            if (n >= 2 && sb.charAt(n - 1) - 'a' == cur[0] && sb.charAt(n - 2) - 'a' == cur[0]) {
                if (q.isEmpty()) {
                    break;
                }
                int[] next = q.poll();
                sb.append((char)(next[0] + 'a'));
                if (--next[1] != 0) {
                    q.add(next);
                }
                q.add(cur);
            } else {
                sb.append((char)(cur[0] + 'a'));
                if (--cur[1] != 0) {
                    q.add(cur);
                }
            }
        }
        return sb.toString();
    }

}
